public class BuilderTest {
    public static void main(String[] args) {
        ProductBuilder productBuilder = new SpecialConcreteProductBuilder();
        Director director = new Director(productBuilder);
        Product2 product2 = director.makeProduct("zs","123","","","","","");
        System.out.println(product2);
    }


}
//创建者接口
interface ProductBuilder{
    void builderName(String name);
    void builderPassword(String password);
    void builderPart1(String part1);
    void builderPart2(String part2);
    void builderPart3(String part3);
    void builderPart4(String part4);
    void builderPart5(String part5);

    Product2 build();
}
//创建者1
class DefaultConcreteProductBuilder implements ProductBuilder{
    private String name;
    private String password;
    private String part1;
    private String part2;
    private String part3;
    private String part4;
    private String part5;
    @Override
    public void builderName(String name) {
            this.name = name;
    }

    @Override
    public void builderPassword(String password) {
            this.password = password;
    }

    @Override
    public void builderPart1(String part1) {
            this.part1 = part1;
    }

    @Override
    public void builderPart2(String part2) {
            this.part2 = part2;

    }

    @Override
    public void builderPart3(String part3) {
            this.part3 = part3;
    }

    @Override
    public void builderPart4(String part4) {
            this.part4 = part4;
    }

    @Override
    public void builderPart5(String part5) {
            this.part5 = part5;
    }

    @Override
    public Product2 build() {
        return new Product2(this.name,this.password,this.part1,this.part2,this.part3,this.part4,this.part5);
    }
}
//创建者2
class SpecialConcreteProductBuilder implements ProductBuilder{
    private String name;
    private String password;
    private String part1;
    private String part2;
    private String part3;
    private String part4;
    private String part5;
    @Override
    public void builderName(String name) {
        this.name = name;
    }

    @Override
    public void builderPassword(String password) {
        this.password = password;
    }

    @Override
    public void builderPart1(String part1) {
        this.part1 = part1;
    }

    @Override
    public void builderPart2(String part2) {
        this.part2 = part2;

    }

    @Override
    public void builderPart3(String part3) {
        this.part3 = part3;
    }

    @Override
    public void builderPart4(String part4) {
        this.part4 = part4;
    }

    @Override
    public void builderPart5(String part5) {
        this.part5 = part5;
    }

    @Override
    public Product2 build() {
        return new Product2(this.name,this.password,this.part1,this.part2,this.part3,this.part4,this.part5);
    }
}
class Director{
    private ProductBuilder builder;
    //构造方法
    public Director(ProductBuilder builder) {
        this.builder = builder;
    }

    public Product2 makeProduct(String name, String password, String part1, String part2, String part3, String part4, String part5){
        builder.builderName(name);
        builder.builderPassword(password);
        builder.builderPart1(part1);
        builder.builderPart2(part2);
        builder.builderPart3(part3);
        builder.builderPart4(part4);
        builder.builderPart5(part5);

        return builder.build();

    }
}
class Product2 {
    private String name;
    private String password;
    private String part1;
    private String part2;
    private String part3;
    private String part4;
    private String part5;
    // ......

    public Product2() {
    }

    public Product2(String name, String password, String part1, String part2, String part3, String part4, String part5) {
        this.name = name;
        this.password = password;
        this.part1 = part1;
        this.part2 = part2;
        this.part3 = part3;
        this.part4 = part4;
        this.part5 = part5;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPart1() {
        return part1;
    }

    public void setPart1(String part1) {
        this.part1 = part1;
    }

    public String getPart2() {
        return part2;
    }

    public void setPart2(String part2) {
        this.part2 = part2;
    }

    public String getPart3() {
        return part3;
    }

    public void setPart3(String part3) {
        this.part3 = part3;
    }

    public String getPart4() {
        return part4;
    }

    public void setPart4(String part4) {
        this.part4 = part4;
    }

    public String getPart5() {
        return part5;
    }

    public void setPart5(String part5) {
        this.part5 = part5;
    }

    @Override
    public String toString() {
        return "Product2{" +
                "name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", part1='" + part1 + '\'' +
                ", part2='" + part2 + '\'' +
                ", part3='" + part3 + '\'' +
                ", part4='" + part4 + '\'' +
                ", part5='" + part5 + '\'' +
                '}';
    }
}